import 'package:Second/routerdemo/user/Home.dart';
import 'package:Second/routerdemo/user/Register.dart';
import 'package:flutter/material.dart';

class TabsLogin extends StatefulWidget {
  final int index;
  TabsLogin({Key? key, this.index = 0}) : super(key: key);

  @override
  _TabsState createState() => _TabsState(index);
}

class _TabsState extends State<TabsLogin> {
  int _currentIndex = 0;
  List pageList = [HomePage(), RegisterPage()];

  _TabsState(index) {
    this._currentIndex = index;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('First Web'),
      ),
      body: pageList[_currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        items: [
          BottomNavigationBarItem(icon: Icon(Icons.home), label: "登录"),
          BottomNavigationBarItem(icon: Icon(Icons.home), label: "注册")
        ],
        currentIndex: this._currentIndex,
        onTap: (index) {
          setState(() {
            this._currentIndex = index;
          });
        },
      ),
    );
  }
}
